package com.example.demo.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.oldpartsmanage;
import com.example.demo.mapper.oldpartsmanageMapper;
import com.example.demo.service.OldpartsmanageService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class OldpartsmanageServiceImpl extends ServiceImpl<oldpartsmanageMapper, oldpartsmanage> implements OldpartsmanageService {
    @Resource
    private oldpartsmanageMapper oldpartsmanageMapper;

    @Override
    public String Storage(@RequestBody oldpartsmanage oldpartsmanage)//输入主键，自动输入时间
    {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");//查询系统时间
        Date date = new Date();
        oldpartsmanage.setWtime(dateFormat.format(date));
        if(oldpartsmanageMapper.Storage(oldpartsmanage)==1)//判断是否插入成功
        {
            return "入库成功";
        }
        else {return "入库失败";}
    }
    @Override
    public List queryoldpartsmanage(@RequestBody oldpartsmanage oldpartsmanage)//输入主键查询信息
    {
        return oldpartsmanageMapper.selectOkey(oldpartsmanage);
    }
    @Override
    public String Outbound(@RequestBody int okey)
    {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");//查询系统时间
        Date date = new Date();
        if(oldpartsmanageMapper.Outbound(okey,dateFormat.format(date))==1)//判断是否成功
        {
            return "出库成功";
        }
        else {return "出库失败";}
    }
    @Override
    public String update(@RequestBody oldpartsmanage oldpartsmanage)//输入数据更新返修件视图
    {
        if(oldpartsmanageMapper.updateoldpartsmanage(oldpartsmanage)==1)
        {
            return "修改成功";
        }
        else {return "修改失败";}
    }
}
